<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
<script type="text/javascript">
function searchTracks() {
	var account = $("#account").val();
	var fromDate = $("#fromDate").val();
	var toDate = $("#toDate").val();
	var check = $("#handOnly").prop("checked");
	var url;
	url = 'ts-track-search-list.action';
	$("#gridTracksSearch").jqGrid('setGridParam', {
		url : url,
		postData : {
			'handOnly' : check,
			'account' : account,
			'fromDate' : fromDate,
			'toDate' : toDate
		}
	}).trigger("reloadGrid");
}
function reportClick() {
	var url="ts-report-trackday.action?report_code=trackday_report";	
	window.open(url);	
}
</script>
<!-- 
<h2>Danh sách thiết bị check in/out</h2>
 -->
<div>
	<s:form theme="xhtml">
		<s:textfield name="account" id="account" label="Account"></s:textfield>
		<sj:datepicker id="fromDate" name="fromDate" label="Date from" displayFormat="dd/mm/yy" buttonImageOnly="true"/>
		<sj:datepicker id="toDate" name="toDate" label="To" displayFormat="dd/mm/yy" buttonImageOnly="true"/>
		<!-- 
		<s:textfield name="toDate" id="toDate" label="To" value="30/06/2014"></s:textfield>
		 -->
		<s:checkbox name="handOnly" id="handOnly" label="Cửa vào chính"></s:checkbox>
	</s:form>
</div>
<sj:a button="true" onclick="searchTracks()">Tìm kiếm</sj:a>
<sj:a 
 	id="reportButton" 
 	href="#" 
 	button="true"
 	accesskey="K"
 	buttonIcon="ui-icon ui-icon-note" 
 	disabled="true"
 	onclick="exportToExcel();">
 	Excel</sj:a>
<div>
	<s:url var="noneurl" action="none" namespace="/"/>
	<sjg:grid
	 	id="gridTracksSearch"
	 	dataType="json"
	 	href="%{noneurl}"
	 	gridModel="histories"
	 	rowNum="-1"
	 	rownumbers="true"
	 	scroll="false"
	   	shrinkToFit="true"
	   	width="500"
	 >
	 	<sjg:gridColumn name="recordID" index="recordID" title="ID" hidden="true" sortable="false" key="true"/>
	 	<sjg:gridColumn name="timeStamp" index="timeStamp" title="Date" sortable="false" displayTitle="false" align="center" width="50"
	 	 	formatter="date" 
	 	 	formatoptions="{newformat : 'd/m/Y', srcformat : 'Y/m/d'}"
	 	/>
	 	<sjg:gridColumn name="cardHolder.lastName" index="cardHolder.lastName" title="Account" sortable="false" align="center" width="70"/>
	 	<sjg:gridColumn name="timeStamp" index="timeStamp" title="TimeStamp" sortable="false" displayTitle="false" align="center" width="50"
	 	 	formatter="date" 
	 	 	formatoptions="{newformat : 'H:i', srcformat : 'Y/m/d H:i:s'}"
	 	/>
	 	<sjg:gridColumn name="note" index="note" title="Note" sortable="false"/>
	 </sjg:grid>
</div>
